﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace ZetaPrints.ZetaClient.Presentation
{
    public enum OSVersionOption
    {
        x64,
        x86,
        Null
    }

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            OSVersionOption application = OSVersionOption.Null;

            if (System.IO.File.Exists("x64.txt"))
            {
                /// ths installation file of the x64 system must have this file in it.
                application = OSVersionOption.x64;
            }
            else
            {
                /// we default to x86 in any case
                application = OSVersionOption.x86;
            }
            
            /// the os is the following
            OSVersionOption operatingSystem = OSVersionOption.Null;

            /// this gives us what version of the os this is.
            if (IntPtr.Size == 8)
            {
                operatingSystem = OSVersionOption.x64;
            }
            else if (IntPtr.Size == 4)
            {
                operatingSystem = OSVersionOption.x86;
            }

            if (application == operatingSystem)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FormMain());
            }
            else
            {
                MessageBox.Show("You are trying to run a " + application.ToString() + " application on a " + operatingSystem.ToString() + " operating system." +
                    " Please download the " + operatingSystem.ToString() + " from the following link:\n" +
                    "http://code.google.com/p/zetaclient/downloads/list");
            }
        }
    }
}
